﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using SKB.ViewModels;
using SKB.Extensions;

namespace SKB.Controllers
{
    public class ProjectController : Controller
    {
        //
        // GET: /Project/
        SKBEntities e = new SKBEntities();

        public ActionResult Index()
        {
            ProjectListViewModel pageModel = new ProjectListViewModel();

            IEnumerable<ProjectViewModel> model = (from r in e.Projects select r).ToProjectViewModel();

            pageModel.List = model;
            pageModel.NewRecord = new ProjectViewModel();

            return View(pageModel);
        }

        //public JsonResult JsonAddWarehouse(ProjectViewModel jsonModel)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        // DistributionViewModel inModel = acquisitionDistributionsViewModel.NewDetail;
        //        Project model = jsonModel.ToProject();

        //        e.Projects.AddObject(model);
        //        e.SaveChanges();

        //        // IEnumerable<WarehouseViewModel> returnModel = (from r in e.Warehouses where r.PartnerID == jsonModel.PartnerID select r).ToWarehouseViewModel();
        //        WarehouseListPageViewModel returnModel = new WarehouseListBusinessModel().GetWarehouseListPageViewModel(jsonModel.PartnerID);

        //        // return a Json Object, you could define a new class
        //        return Json(new
        //        {
        //            Success = true,
        //            Message = "The Warehouse has been created!",
        //            PartialViewHtml = RenderPartialViewToString("WarehouseListView", returnModel.Warehouses)
        //        });
        //    }

        //    return null;
        //}

    }
}
